package com.xiaotu.server.controller;

import org.apache.commons.lang.exception.ExceptionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.xiaotu.common.aop.PageProcessLogAspect;
import com.xiaotu.server.model.SpiderParam;
import com.xiaotu.server.service.SpiderDanMuRunService;

/**
 * @类名 SpiderRunnerController
 * @日期 2019年8月2日
 * @作者 王艳龙
 * @功能 运行爬虫弹幕控制器
 */
@RestController
@RequestMapping("/spiderDanMuRunner")
public class SpiderDanMuRunnerController
{
	private static final Logger LOGGER = LoggerFactory
			.getLogger(PageProcessLogAspect.class);
	
	@Autowired
	private SpiderDanMuRunService service;
	
	@RequestMapping("runSpiderDanMuAndSend")
	public Object runSpiderDanMuAndSend(@RequestBody SpiderParam param)
			throws Exception
	{
		try
		{
			service.runSpiderDanMuAndSend(param.getParaMap(), param.getTargetList());
			return "0";
		}
		catch (Exception e)
		{
			LOGGER.error(ExceptionUtils.getStackTrace(e));
			return "1";
		}
	}
/*	
	@RequestMapping(value = "/forward")
	public ModelAndView forward(ModelAndView mv)
	{
		mv.setViewName("spiderDanMu");
		return mv;
	}*/
	
}
